<?PHP
namespace app\index\controller\v1;

use app\index\controller\Base;
use app\index\model\Article;

class Content extends Base
{
    /**
     * 资源列表
     */
    public function list(){ 
        $params = input();
        $offset = $this->getOffset($params['pageNo'],$params['pageSize']);
        
     $info= Article::limit($offset,(int)$params['pageSize'])->select();
     $total = Article::count();
       return $this->pagination($total, $info);
    }
    /**
     * 新增
     */
    public function save(){ 
        $params = input();
        $errM = $this->validate(
            $params,
            'app\index\validate\Article'
        );
        if (true !== $errM) {
            return $this->errMsg($errM);
        } else {
            $article = new Article;
            $article->data($params);
            $article->save();
            if($article->id){
                return $this->okMsg("添加成功", $article->id);
            }else{
                return $this->okMsg("添加失败");
            }
           
        }
    }
    public function delete(){ 

    }
    public function update(){ 

    }
    public function read(){ 

    }
}

